package club.looli.haoke.api.service;

import club.looli.haoke.api.vo.Pagination;
import club.looli.haoke.api.vo.TableResult;
import club.looli.haoke.common.vo.PageInfo;
import club.looli.haoke.houseResources.api.ApiHouseResourcesService;
import club.looli.haoke.houseResources.entity.HouseResources;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

/**
 * <p>
 * Created by looli on 2020/7/7
 * </p>
 *
 * <p>
 *
 * </p>
 *
 * @author looli
 * @since 2020/7/7
 */
@Service
public class HouseResourcesService {

    @Reference(version = "1.0.0")
    private ApiHouseResourcesService apiHouseResourcesService;

    public boolean save(HouseResources houseResources){
        int result = this.apiHouseResourcesService.saveHouseResources(houseResources);
        return result == 1;
    }


    public TableResult<HouseResources> queryList(HouseResources houseResources, Integer currentPage, Integer pageSize) {
        PageInfo<HouseResources> pageInfo = apiHouseResourcesService.queryHouseResourcesList(currentPage, pageSize, houseResources);
        TableResult<HouseResources> result = new TableResult<HouseResources>(pageInfo.getRecords(),
                new Pagination(pageInfo.getPageNum(),pageInfo.getPageSize(),pageInfo.getTotal()));
        return result;
    }

    public HouseResources queryById(Long id) {
        return apiHouseResourcesService.queryHouseResourcesById(id);
    }
}
